package com.ibeeking.found.id.rest.controller.v1.feign;

import com.ibeeking.found.id.api.common.dto.*;
import com.ibeeking.found.id.rest.service.ISerialNoRuleGenerateService;
import com.ibeeking.found.id.service.common.param.*;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;

@RestController
@RequestMapping("/id/serialNoRule/feign/v1")
public class SerialNoRuleFeignController {

    @Resource
    private ISerialNoRuleGenerateService serialNoRuleGenerateServiceImpl;

    @PostMapping(value = "/generateSerialNo/{keyCode}")
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询规则号")
    public SerialNumberDTO generateSerialNo(@PathVariable("keyCode") @NotBlank(message = "keyCode必填") String keyCode){
        return serialNoRuleGenerateServiceImpl.generateSerialNo(keyCode);
    }

    @PostMapping(value = "/generateSerialNo")
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "获取规则的编号")
    public SerialNumberDTO generateSerialNo(@RequestBody  List<NoRuleDTO> ruleDTOS, @RequestParam("keyCode") String keyCode)throws ServiceException {
        return serialNoRuleGenerateServiceImpl.generateSerialNo(ruleDTOS,keyCode);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存合同规则code")
    @PostMapping(value = "/saveContractSerialNoRule")
    public Boolean saveContractSerialNoRule(@RequestBody @Validated List<ContractSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveContractSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询合同规则code")
    @PostMapping(value = "/queryContractSerialNoRule")
    public List<ContractSerialNoRuleDTO> queryContractSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryContractSerialNoRule();
    }
    /*
     * 订单规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存订单规则code")
    @PostMapping(value = "/saveOrderSerialNoRule")
    public Boolean saveOrderSerialNoRule(@RequestBody @Validated List<OrderSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveOrderSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询订单规则code")
    @PostMapping(value = "/queryOrderSerialNoRule")
    public List<OrderSerialNoRuleDTO> queryOrderSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryOrderSerialNoRule();
    }
    /*
     * 会员卡号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存会员卡号规则code")
    @PostMapping(value = "/saveMemberCardNoRule")
    public Boolean saveMemberCardNoRule(@RequestBody @Validated List<MemberCardNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveMemberCardNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询会员卡号规则code")
    @PostMapping(value = "/queryMemberCardNoRule")
    public List<MemberCardNoRuleDTO> queryMemberCardNoRule() {
        return serialNoRuleGenerateServiceImpl.queryMemberCardNoRule();
    }
    /*
     * 库存入库单号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存库存入库单号规则code")
    @PostMapping(value = "/saveInstockSerialNoRule")
    public Boolean saveInstockSerialNoRule(@RequestBody @Validated List<InstockSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveInstockSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询库存入库单号规则code")
    @PostMapping(value = "/queryInstockSerialNoRule")
    public List<InstockSerialNoRuleDTO> queryInstockSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryInstockSerialNoRule();
    }
    /*
     * 库存出库单号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存库存出库单号规则code")
    @PostMapping(value = "/saveOutstockSerialNoRule")
    public Boolean saveOutstockSerialNoRule(@RequestBody @Validated List<OutstockSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveOutstockSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询库存出库单号规则code")
    @PostMapping(value = "/queryOutstockSerialNoRule")
    public List<OutstockSerialNoRuleDTO> queryOutstockSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryOutstockSerialNoRule();
    }
    /*
     * 库存盘点单号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存盘点单号规则code")
    @PostMapping(value = "/saveInvCheckSerialNoRule")
    public Boolean saveInvCheckSerialNoRule(@RequestBody @Validated List<InvCheckSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveInvCheckSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询盘点单号规则code")
    @PostMapping(value = "/queryInvCheckSerialNoRule")
    public List<InvCheckSerialNoRuleDTO> queryInvCheckSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryInvCheckSerialNoRule();
    }

}
